//
//  CHOAuthViewModel.swift
//  Checked
//
//  Created by admin on 11/03/2017.
//  Copyright © 2017 shinolr_go. All rights reserved.
//

import UIKit

class CHUserAccountViewModel: NSObject {

	/// 单例全局放问点
	static let sharedUserAccount: CHUserAccountViewModel = CHUserAccountViewModel()

	/// 请求 authorize
	///
	/// - Parameter callBack: 返回请求
	func requestAuthorize(callBack: @escaping (URLRequest?) -> Void) {
//        NetworkManager.sharedManager.request(target: TraktApi.authorize) { (moyaResponse, error) in
//            if error != nil {
//                print(error!)
//                return
//            }
//
//            let request = moyaResponse?.request  // https://trakt.tv/oauth/authorize?client_id=0d1813849638e4ae85af190eb3c0c7899f2d296d5852c2b8f6d50efdf2290332&redirect_uri=http%3A//www.baidu.com&response_type=code
//
//            callBack(request)
//        }
	}

	/// 获取 accessToken
	///
	/// - Parameters:
	///   - code: code
	///   - callBack: 是否请求成功
	func requestAccesToken(code: String, callBack: @escaping (Bool) -> Void) {
//        NetworkManager.sharedManager.request(target: TraktApi.accessToken(code: code), callBack: { (moyaResponse, error) in
//            if error != nil {
//                print(error!)
//                callBack(false)
//                return
//            }
//
////            do {
////                let userAccount = try moyaResponse?.map(to: CHUserAccountModel.self)
////                accessToken = userAccount?.access_token
////            } catch {
////                print(error)
////            }
//
//            self.requestAllShows(callBack: callBack)
//        })
	}

	/// 获取全部剧集信息
	///
	/// - Parameter callBack: 是否请求成功
	private func requestAllShows(callBack: @escaping (Bool) -> Void) {
//        NetworkManager.sharedManager.request(target: TraktApi.allShows, header: true, callBack: { (moyaResponse, error) in
////            let data = moyaResponse?.data
////            let json = JSON(data: data!)
////            callBack(true)
////            print(json)
//        })
	}
}
